package com.dykj.fireFighting.server.socialUnit.fireNotice.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dykj.fireFighting.api.socialUnit.fireNotice.dto.FireNoticeDto;
import com.dykj.fireFighting.api.socialUnit.fireNotice.entity.FireNotice;
import com.dykj.fireFighting.api.socialUnit.fireNotice.service.IFireNoticeService;
import com.dykj.fireFighting.common.core.service.impl.BaseServiceImpl;
import com.dykj.fireFighting.common.core.vo.PageVo;
import com.dykj.fireFighting.server.socialUnit.fireNotice.mapper.FireNoticeMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 消防公告
 *
 * @Author hxb
 * @Date 2021-06-23 08:58:01
 */
@Slf4j
@DubboService
@Transactional(rollbackFor = Exception.class)
public class FireNoticeServiceImpl extends BaseServiceImpl<FireNoticeMapper, FireNotice> implements IFireNoticeService {

    @Autowired
    private FireNoticeMapper fireNoticeMapper;

    @Override
    public PageVo pageList(FireNoticeDto fireNoticeDto) {
        Map<String, Object> params = new HashMap<String, Object>();
        if (StringUtils.isNotBlank(fireNoticeDto.getTitle())) {
            params.put("title", "%" + fireNoticeDto.getTitle() + "%");
        }
        params.put("enterpriseType", 0);
        params.put("unitId", fireNoticeDto.getUnitId());
        params.put("beginDate",fireNoticeDto.getBeginDate());
        params.put("endDate",fireNoticeDto.getEndDate());
        Page page = new Page();
        // 设置当前页码
        page.setCurrent(fireNoticeDto.getPage());
        // 设置页大小
        page.setSize(fireNoticeDto.getLimit());
        return new PageVo<FireNotice>(fireNoticeMapper.pageList(page, params));
    }

    @Override
    public int updateByIds(List<String> ids) {

        return this.baseMapper.updateIsDel(ids);
    }
}
